<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <span v-on:click="add(item)" v-for="item in list"
        ><input type="checkbox" /><span>{{ item }}</span></span
      >
      <ul>
        <li v-for="item in list01">{{ item }}</li>
      </ul>
    </div>
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          list: [
            "科幻",
            "喜剧",
            "动漫",
            "冒险",
            "科技",
            "军事",
            "娱乐",
            "奇闻",
          ],
          list01: [],
        },
        methods: {
          add(item) {
            const index = this.list01.indexOf(item);
            console.log(index)
            if (index > -1) {
              this.list01.splice(index, 1);
            }else{
                this.list01.push(item);
                console.log(this.list01);
            }
  
          },
        },
      });
    </script>
  </body>
</html>
